<template>
	<view class="cart">
		<view class="shop-list">

			<view class="item-box">
				<view class="item">
					<!-- 左侧icon选择 -->
					<view class="check-around-box">
						<icon v-if='selected' type="success_circle" color="#51b897" />
						<icon v-else type="circle" />
					</view>
					<!-- 图片 -->
					<view class="item-img-box">
						<image class="item-img" src="" />
					</view>
					<!-- 商品介绍 -->
					<view class="item-info-box">
						<view class="item-title">ww</view>
						<view class="item-spec">33</view>

						<view class="item-price">¥33</view>

						<view class="num-box">
							<view class="num-desc">-</view>
							<input class="item-input" type="number" disabled="boolean" />
							<view class="num-plus">+</view>

						</view>
					</view>
				</view>

				<view class="remove">删除</view>

			</view>

		</view>


		<!-- ----购买 -->
		<view class='bottom'>
			<view class='all'>
				<!-- wx:if 是否全选显示不同图标 -->
				<icon v-if='selectedAll' type="success_circle" />
				<icon v-else type="circle" />
				<text class="check-all">全选</text>

			</view>

			<view class='sum'>
				<text class='he'>合计</text>
				<text>99</text>
				<text class='small'>不含运费</text>
			</view>

			<view class='balance'>结算</view>
			<view class='balance-gray balance'>结算</view>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				selected: true, //选中商品
				selectedAll:true,//全选
				list:[],//购物车的数据
			}
		},
		onLoad() {
			this.cartList()
		},
		methods: {
			//获取购物车列表数据----
			//正常情况：访问购物车的数据需要登录 用token字段作为请求头校验
			async cartList() {
				let res = await uni.$http(uni.$base.cartList)
				console.log('购物车列表数据----', res);
				if(res.status==200){
					this.list = res.data.result;
				}else{
					this.list=[]
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.cart {
		background-color: #f5f5f5;
		height: calc(100vh);
	}

	.shop-list {
		display: flex;
		flex-direction: column;
		padding-bottom: 160rpx;
	}

	.item-box {
		margin-bottom: 20rpx;
		position: relative;
		font-size: 28rpx;
		display: flex;
		justify-content: space-between;
		width: 100%;
		overflow: hidden;
		background: #fff;
	}

	.item {
		display: flex;
		align-items: center;
		padding: 20rpx;
		position: relative;
		width: 100%;
		margin-right: 0;
		transition: all 0.4s;
		-webkit-transition: all 0.4s;
		-webkit-transform: translateX(90px);
		transform: translateX(90px);
		margin-left: -90px;
	}

	.item-img-box {
		margin-left: 10rpx;
	}

	.item .item-img {
		width: 180rpx;
		height: 180rpx;
		border-radius: 5rpx;
		border: 1rpx solid #eee;
		padding-left: 10rpx;
	}

	.item .item-info-box {
		width: 420rpx;
		height: 200rpx;
		margin-left: 20rpx;
		position: relative;
	}

	.item-info-box .item-title {
		font-size: 30rpx;
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
		word-break: break-all;
	}

	.item-info-box .item-spec {
		color: #676767;
		margin-top: 15rpx;
		text-overflow: -o-ellipsis-lastline;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		line-clamp: 2;
		-webkit-box-orient: vertical;
	}

	.item-info-box .item-price {
		margin-top: 15rpx;
		color: red;
	}

	.item-info-box .num-box {
		display: flex;
		align-items: center;
		justify-content: flex-end;
		font-size: 30rpx;
		position: absolute;
		right: 0;
		bottom: 0rpx;

	}

	.num-box .num-desc {
		padding: 0 10rpx;
		color: #999;
		border: 4rpx solid #999;
	}

	.num-box .item-input {
		width: 80rpx;
	}

	.item-input {
		text-align: center;
	}

	.num-box .num-plus {
		padding: 0 10rpx;
		color: #fff;
		background-color: #000;
		border: 4rpx solid #000;
	}

	.remove {
		background-color: orangered;
		width: 180rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		color: #fff;
		-webkit-transform: translateX(90px);
		transform: translateX(90px);
		-webkit-transition: all 0.4s;
		transition: all 0.4s;
	}

	.touch-move-active .item,
	.touch-move-active .remove {
		-webkit-transform: translateX(0);
		transform: translateX(0);
	}

	/* 结算 */

	.bottom {
		position: fixed;
		background: #fff;
		display: flex;
		bottom: 0;
		left: 0;
		right: 0;
	}

	.all {
		display: flex;
		align-items: center;
		padding-left: 20rpx;
	}

	.sum text {
		color: #51b897;
	}

	.sum {
		flex: 1;
		padding-top: 20rpx;
		text-align: right;
	}

	.sum .he {
		color: #000;
		margin-right: 10rpx;
	}

	.sum .small {
		font-size: 24rpx;
		color: #999;
		margin-left: 10rpx;
	}

	.balance {
		margin-left: 10rpx;
		padding: 20rpx;
		text-align: right;
		background: #51b897;
		color: #fff;
	}

	.balance-gray {
		background: #999;
	}
</style>
